<?php use_helper('Javascript') ?>
<script type="text/javascript">
function disableCheckbox(checkbox, disable) {
      var max = checkbox.length;
      for (var i=0; i<max; i++) {
        checkbox[i].disabled = disable;
      }
     
    }
</script>
<?php echo __('Visible for:');?><br/>
<div id="show" >
    <?php $i = 0;?>
    <?php foreach( $arRoles as $roleKey => $roleValue ): ?>
        <?php $i = $i+1;?>
            <?php echo checkbox_tag('calendar[visible_role][' . $i . ']'
                                , $roleKey
                                , (!empty($arVisibleRoles[$roleKey])) ? 1:0
                                , array('id' => 'show'
                                        , (($calendar->getUserRoles() == '')? ('disabled'): '') => ($calendar->getUserRoles() == '')? ('disabled'): ''
                                        ));?>
        <?php echo __($roleValue); ?>
        <br />
    <?php endforeach; ?>
</div>
<?php echo checkbox_tag('calendar[visible_all]'
                    , 1 
                    , ($calendar->getUserRoles() == '')?1:0
                    , array('onClick' => "disableCheckbox(document.sf_admin_edit_form.show, this.checked ? true : false);"
                    //'onclick' => "document.getElementById('show').disabled = this.checked ? 'false' : 'true'"
                    , 'id' => 'all') );?>
<?php echo __('All');?>
<script type="text/javascript">
function disableCheckbox(checkbox, disable) {
      var max = checkbox.length;
      for (var i=0; i<max; i++) {
        checkbox[i].disabled = disable;
      }
     
    }
</script>